package com.moetube.web.controller;

import com.alibaba.fastjson.JSON;
import com.moetube.video.feign.BarrageFeign;
import com.moetube.video.feign.CommentFeign;
import com.moetube.video.feign.VideoFeign;
import com.moetube.video.pojo.Barrage;
import com.moetube.video.pojo.Comment;
import com.moetube.video.pojo.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @description:视频渲染服务
 * @author: xc
 * @time: 2020/01/02 15:32
 */
@Controller
@RequestMapping("/wvideo")
public class VideoController {
    @Autowired
    private VideoFeign videoFeign;

    @Autowired
    private BarrageFeign barrageFeign;

    @Autowired
    private CommentFeign commentFeign;

    @GetMapping("/{videoId}")
    public String video(@PathVariable("videoId") String videoId, Model model) {
//        if("{{".startsWith(videoId)){
//            return null;
//        }
//        Video video1 = videoFeign.findById(videoId).getData();
//        //String video = JSON.toJSONString(video1);
//        model.addAttribute("video", video1);
//
//
//
//        List<Barrage> barrageList1 = barrageFeign.findListByVideoId(videoId).getData();
//        String barrageList = JSON.toJSONString(barrageList1);
//        model.addAttribute("barrageList", barrageList);
//
//        List<Comment> commentList1 = commentFeign.findByVideoId(videoId).getData();
//        String commentList = JSON.toJSONString(commentList1);
//        model.addAttribute("comment", commentList);

        model.addAttribute("videoId",videoId);

        return "video";
    }

    @RequestMapping("/test")
    public String test(){
        return "video";
    }


}
